/**
 * Created by shenyinlin on 2018/6/24.
 */

//小马类
//循环渲染三只小马
//循环渲染三只小马的部分

import {Sprite} from "../base/Sprite.js";
import {DataStore} from "../base/DataStore.js";
export class HomeBackground extends Sprite {

    constructor() {

        const image = Sprite.getImage('homeBackground');

        super(image, 0, 0,
            image.width, image.height,
            0, 0,
            image.width, image.height);
        this.image = image;

    }




    draw(){

        var div_width= DataStore.getInstance().canvas.width;
        var div_height= DataStore.getInstance().canvas.height;
        var old_width= this.image.width;
        var old_height= this.image.height;

        var scale_x=div_width*old_width/old_height;
        var scale_y=div_width*old_height/old_width;



        if(old_height>old_width){
            super.draw(this.image, 0, 0,
                this.image.width, this.image.height,
                0,-(scale_y-div_width)/2,
                div_width,scale_y);
          //  ctx.drawImage(image,0,0,old_width,old_height,0,-(scale_y-div_width)/2,div_width,scale_y);

        }else{
            super.draw(this.image, 0, 0,
                this.image.width, this.image.height,
                -(scale_x-div_width)/2,0,
                scale_x,div_height);
            //ctx.drawImage(image,0,0,old_width,old_height,-(scale_x-div_width)/2,0,scale_x,div_width);
        }



    }

}